# movie_app/admin.py
from django.contrib import admin
from .models import Movie
from .forms import MovieForm
from django.utils.html import format_html

class MovieAdmin(admin.ModelAdmin):
    form = MovieForm
    list_display = ('title', 'release_year', 'display_poster')
    readonly_fields = ('display_poster',)
    
    def display_poster(self, obj):
        if obj.poster_url:
            return format_html('<img src="{}" width="150" />', obj.poster_url)
        return "无海报"
    display_poster.short_description = '海报预览'

admin.site.register(Movie, MovieAdmin)
